package com.ocean.productDict.service.impl;

import java.util.Date;
import java.util.List;
import java.util.UUID;

import com.ocean.common.core.domain.entity.SysUser;
import com.ocean.common.utils.ShiroUtils;
import com.ocean.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ocean.productDict.mapper.OForecastTypeMapper;
import com.ocean.productDict.domain.OForecastType;
import com.ocean.productDict.service.IOForecastTypeService;
import com.ocean.common.core.text.Convert;

/**
 * 预报类型维护Service业务层处理
 *
 * @author ocean
 * @date 2022-12-30
 */
@Service
public class OForecastTypeServiceImpl implements IOForecastTypeService
{
    @Autowired
    private OForecastTypeMapper oForecastTypeMapper;

    /**
     * 查询预报类型维护
     *
     * @param id 预报类型维护主键
     * @return 预报类型维护
     */
    @Override
    public OForecastType selectOForecastTypeById(String id)
    {
        return oForecastTypeMapper.selectOForecastTypeById(id);
    }

    /**
     * 查询预报类型维护列表
     *
     * @param oForecastType 预报类型维护
     * @return 预报类型维护
     */
    @Override
    public List<OForecastType> selectOForecastTypeList(OForecastType oForecastType)
    {
        return oForecastTypeMapper.selectOForecastTypeList(oForecastType);
    }

    /**
     * 新增预报类型维护
     *
     * @param oForecastType 预报类型维护
     * @return 结果
     */
    @Override
    public int insertOForecastType(OForecastType oForecastType)
    {
        oForecastType.setId(IdUtils.simpleUUID());
        SysUser sysUser = ShiroUtils.getSysUser();
        oForecastType.setCreateName(sysUser.getUserName());
        oForecastType.setCreateBy(sysUser.getLoginName());
        oForecastType.setCreateDate(new Date());
        oForecastType.setUpdateName(sysUser.getUserName());
        oForecastType.setUpdateBy(sysUser.getLoginName());
        oForecastType.setUpdateDate(new Date());
        return oForecastTypeMapper.insertOForecastType(oForecastType);
    }

    /**
     * 修改预报类型维护
     *
     * @param oForecastType 预报类型维护
     * @return 结果
     */
    @Override
    public int updateOForecastType(OForecastType oForecastType)
    {
        SysUser sysUser = ShiroUtils.getSysUser();
        oForecastType.setUpdateName(sysUser.getUserName());
        oForecastType.setUpdateBy(sysUser.getLoginName());
        oForecastType.setUpdateDate(new Date());
        return oForecastTypeMapper.updateOForecastType(oForecastType);
    }

    /**
     * 批量删除预报类型维护
     *
     * @param ids 需要删除的预报类型维护主键
     * @return 结果
     */
    @Override
    public int deleteOForecastTypeByIds(String ids)
    {
        return oForecastTypeMapper.deleteOForecastTypeByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除预报类型维护信息
     *
     * @param id 预报类型维护主键
     * @return 结果
     */
    @Override
    public int deleteOForecastTypeById(String id)
    {
        return oForecastTypeMapper.deleteOForecastTypeById(id);
    }
}
